import 'package:flutter/foundation.dart';
import 'package:dio/dio.dart';
import 'package:body_measurement/common/global.dart';

class MeyHttpInterceptor extends InterceptorsWrapper {
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    if (options.path != '/token/get') {
      debugPrint(Global.token);
      options.headers['X-Token'] = Global.token;
    }

    super.onRequest(options, handler);
  }

  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
    debugPrint('${response.requestOptions}');
    super.onResponse(response, handler);
  }

  @override
  void onError(DioException err, ErrorInterceptorHandler handler) {
    // TODO: implement onError
    super.onError(err, handler);
  }
}
